import XEUtils from 'xe-utils';

export default {
    // 获取验证码
    API_GetVerifyCode: '/api/v2/getVerifyCode.action',
    // 登录
    API_Login: '/api/v2/login.action',
    // 刷新Token
    API_RefreshToken: '/api/v2/refreshToken.action',
    API_Forward: '/api/v2/forward.action',
    //根据格式返回当前时间字符串,参数有：format
    API_GetNowStrWithFormat: '/api/v2/getNowStrWithFormat.action',
    //返回从某个基准时间开始的毫秒数,参数是base_time,format
    API_GetMillisFromBaseTime: '/api/v2/getMillisFromBaseTime.action',
    // 公共参数
    API_FindCommonParameterValuesByKey: '/api/v2/findCommonParameterValuesByKey.action',
    API_GetCommonParameterValueBySid: '/api/v2/getCommonParameterValueBySid.action',
    API_FindParameterValuesByKeyAndValue: '/api/v2/findParameterValuesByKeyAndValue.action',
    API_FindCommonParameterList: '/api/v2/findCommonParameterList.action',
    API_FindCommonParameterValues: '/api/v2/findCommonParameterValues.action',
    API_DeleteCommonParameterValues: 'api/v2/deleteCommonParameterValues.action',
    // 序号表
    API_GetCommonSnValueByCode: '/api/v2/getCommonSnValueByCode.action',
    // 参数管理
    API_FindCommonParameters: '/api/v2/findCommonParameters.action',
    API_SaveCommonParameterValue: '/api/v2/saveCommonParameterValue.action',
    API_DeleteCommonParameterValue: '/api/v2/deleteCommonParameterValue.action',
    API_GetQueryValue4ViewAttachBySid: '/api/v2/getQueryValue4ViewAttachBySid.action',
    // Excel导出
    // 通用导出
    API_ExportExcel: '/api/v2/exportExcel.action',
    API_ExportExcel4MultiHead: '/api/v2/exportExcel4MultiHead.action',
    // 通用模板导出
    API_ExportExcelTemplate: '/api/v2/exportExcelTemplate.action',
    //通用模板导出（多页）
    API_ExportExcelTemplateMultiSheet: '/api/v2/exportExcelTemplateMultiSheet.action',
    // Excel导入
    // 读取Excel数据
    API_ReadExcel: '/api/v2/readExcel.action',
    // 表格设置
    API_QueryCommonTableSetting4User: '/api/v2/queryCommonTableSetting4User.action',
    API_SaveCommonTableSetting: '/api/v2/saveCommonTableSetting.action',
    // 首页
    API_FindMonthStatistics: '/api/v2/findMonthStatistics.action',
    API_FindEchartStatistics: '/api/v2/findEchartStatistics.action',
    getApiUrl(path) {
        const requestPrefix = `${window.configs.requestPrefix.indexOf('/') === 0 ? ''
            : (window.configs.requestPrefix.indexOf('http') === 0 ? '' : '/')}${window.configs.requestPrefix}`;
        if (requestPrefix.indexOf('http') === 0) {
            return `${requestPrefix}${path}`;
        }
        let url = `http:${requestPrefix}${path}`;
        const urlObj = XEUtils.parseUrl(url);
        if (urlObj.host === 'http') {
            url = `${XEUtils.locat().origin}${requestPrefix}${path}`;
        }
        return url;
    },
};
